/*
 * Server.h
 *
 *  Created on: 2009-01-10
 *      Author: tomaszd
 */

#ifndef UdpServer_H_
#define UdpServer_H_

#include "structs.h"
#include <vector>
#include "../CommunicationStructs.h"

class UdpServer {
public:
	struct sockaddr_in udp_server_addr, game_addr, udp_player_addr, none_addr;
	struct timeval tv;
	int addr_len;
	socklen_t slen;
	int sh;
	struct options udp_server_options;
	ClientComunicationStruct udp_player_decl;

	struct init init_struct;
	struct map game_map;
	ClientComunicationStruct udp_player_move;
	struct moves udp_players_moves;
	std::vector <UdpPlayer>  udpPlayers_list ;	// lista przechowujaca graczy

	UdpServer();
	virtual ~UdpServer();

	void udpServerConfig();
	void init();
	void printUdpPlayers();
	bool chceckNickUnique (char *name);
	int addUdpPlayers();
	void send(char *str, unsigned long int size);
	int receiveUdpPlayersMoves (unsigned long int sn);// ret -11 on timeout
};

#endif /* UdpServer_H_ */
